home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-29 | 10.1 KB | 181 lines | [TEXT/MEDT] |
- IMPLEMENTATION MODULE M2TA; (* NW 7.4.83; WH 10.1.86; HS 19.12.91 *)
-
- (* Implementation for the MOTOROLA 68000/68010/68020/68040 processors. *)
-
- FROM M2DA IMPORT
- WordSize, NilVal, ObjPtr, Object, ObjClass, StrPtr, Structure, StrForm,
- Standard, ParPtr, Parameter, PDesc, PDPtr, KeyPtr, Key,
- mainmod, sysmod, MaxInt,
- undftyp, cardtyp, inttyp, booltyp, chartyp, bitstyp,
- realtyp, lrltyp, lwordtyp, dbltyp, proctyp, notyp, stringtyp,
- addrtyp, bytetyp, wordtyp, ALLOCATE, ^.left := ob1 ELSE ob0^.right := ob1 END;
- ob1^.left := NIL; ob1^.right := NIL; ob1^.exported := FALSE;
- IF (obj^.class = Typ) & (obj^.typ^.form = Enum) THEN
- (*import enumeration constants too*)
- ob0 := obj^.typ^.ConstLink;
- WHILE ob0 # NIL DO
- NewImp(scope, ob0); ob0 := ob0^.conval.prev
- END
- END;
- EXIT
- END
- END
- END NewImp;
-
- PROCEDURE NewPar(ident: INTEGER; isvar: BOOLEAN; last: ParPtr): ParPtr;
- VAR par: ParPtr;
- BEGIN ALLOCATE(par, SIZE(Parameter)); par^.name := ident;
- par^.varpar := isvar; par^.next := last; RETURN par
- END NewPar;
-
- PROCEDURE NewScope(cl: ObjClass);
- VAR hd: ObjPtr;
- BEGIN ALLOCATE(hd, SIZE(Object));
- WITH hd^ DO
- name := 0; typ := NIL; class := Header;
- left := topScope; right := NIL; last := hd; next := NIL; kind := cl
- END;
- topScope := hd
- END NewScope;
-
- PROCEDURE CloseScope;
- BEGIN topScope := topScope^.left
- END CloseScope;
-
- PROCEDURE CheckUDP(obj, node: ObjPtr);
- (*obj is newly defined type; check for undefined forward references
- pointing to this new type by traversing the tree*)
- BEGIN
- IF node # NIL THEN
- IF (node^.class = Typ) & (node^.typ^.form = Pointer) &
- (node^.typ^.PBaseTyp = undftyp) &
- (Diff(node^.typ^.BaseId, obj^.name) = 0) THEN
- node^.typ^.PBaseTyp := obj^.typ
- END;
- CheckUDP(obj, node^.left); CheckUDP(obj, node^.right)
- END
- END CheckUDP;
-
- PROCEDURE MarkHeap;
- BEGIN ALLOCATE(topScope^.heap, 0); topScope^.name := id
- END MarkHeap;
-
- PROCEDURE ReleaseHeap;
- BEGIN ResetHeap(topScope^.heap); id := topScope^.name
- END ReleaseHeap;
-
- PROCEDURE InitTableHandler;
- BEGIN topScope := universe; mainmod^.firstObj := NIL; ReleaseHeap
- END InitTableHandler;
-
- PROCEDURE EnterTyp(VAR str: StrPtr; name: ARRAY OF CHAR;
- frm: StrForm; sz: INTEGER);
- BEGIN obj := NewObj(Enter(name), Typ); str := NewStr(frm);
- obj^.typ := str; str^.strobj := obj; str^.size := sz;
- obj^.exported := expo
- END EnterTyp;
-
- PROCEDURE EnterProc(name: ARRAY OF CHAR; num: Standard; res: StrPtr);
- BEGIN obj := NewObj(Enter(name), Code);
- obj^.typ := res; obj^.std := num; obj^.exported := expo
- END EnterProc;
-
- BEGIN topScope := NIL; Scope := NIL;
- NewScope(Module); universe := topScope;
- undftyp := NewStr(Undef); undftyp^.size := 1;
- notyp := NewStr(Undef); notyp^.size := 0;
- stringtyp := NewStr(String); stringtyp^.size := 0;
- BBtyp := NewStr(Range); (*Bitset Basetyp*)
- ALLOCATE(mainmod, SIZE(Object));
- WITH mainmod^ DO
- class := Module; modno := 0; typ := notyp; next := NIL; exported := FALSE;
- ALLOCATE(key, SIZE(Key))
- END;
-
- (*initialization of Universe*)
- expo := FALSE;
- EnterTyp(booltyp, "BOOLEAN", Bool, 1);
- EnterTyp(chartyp, "CHAR", Char, 1);
- EnterTyp(inttyp, "INTEGER", Int, 2);
- EnterTyp(cardtyp, "CARDINAL", Range, 2);
- EnterTyp(bitstyp, "BITSET", Set, WordSize DIV 8);
- EnterTyp(dbltyp, "LONGINT", Double, 4);
- EnterTyp(realtyp, "REAL", Real, 4);
- EnterTyp(lrltyp, "LONGREAL", LongReal, 8);
- EnterTyp(proctyp, "PROC", ProcTyp, 4);
-
- (*initialization of module SYSTEM*)
- NewScope(Module);
- expo := TRUE;
- EnterTyp(bytetyp, "BYTE", Byte, 1);
- EnterTyp(wordtyp, "WORD", Word, 2);
- EnterTyp(lwordtyp, "LONGCARD", LWord, 4);
- EnterTyp(addrtyp, "ADDRESS", LWord, 4);
- EnterProc('ADR', Adr, addrtyp);
- EnterProc('TSIZE', Tsize, inttyp);
- EnterProc('INLINE', Inline, notyp);
- EnterProc('REG', Reg, dbltyp);
- EnterProc('SETREG', Setreg, notyp);
- EnterProc('ASH', XAsh, inttyp);
- EnterProc('LSH', XLsh, inttyp);
- EnterProc('MSK', XMsk, inttyp);
- EnterProc('ROT', XRot, inttyp);
- EnterProc('VAL', Val, inttyp);
- EnterProc('LONG', Long, dbltyp);
- EnterProc('SHORT', Short, inttyp);
- EnterProc('Sqrt', Sqrt, realtyp);
- EnterProc('Entier', Entier, dbltyp);
- EnterProc('Round', Round, dbltyp);
-
- ALLOCATE(sysmod, SIZE(Object));
- WITH sysmod^ DO
- name := Enter("SYSTEM"); class := Module; modno := 0; exported := FALSE;
- left := NIL; right := NIL; next := NIL;
- firstObj := topScope^.right; root := topScope^.right;
- ALLOCATE(key, SIZE(Key))
- END;
- CloseScope;
-
- (* initialization of Universe continued *)
- expo := FALSE;
-
- obj := NewObj(Enter("FALSE"), Const);
- obj^.typ := booltyp; obj^.conval.B := FALSE;
- obj := NewObj(Enter("TRUE"), Const);
- obj^.typ := booltyp; obj^.conval.B := TRUE;
- obj := NewObj(Enter("NIL"), Const);
- obj^.typ := addrtyp; obj^.conval.D := NilVal;
- WITH cardtyp^ DO
- RBaseTyp := inttyp; min := 0; max := MaxInt; size := 2;
- END;
- bitstyp^.SBaseTyp := BBtyp;
- WITH BBtyp^ DO
- RBaseTyp := inttyp; min := 0; max := WordSize - 1; size := 2;
- END;
- proctyp^.firstPar := NIL; proctyp^.resTyp := notyp;
-
- EnterProc('ABS', Abs, inttyp);
- EnterProc('CAP', Cap, chartyp);
- EnterProc('CHR', Chr, chartyp);
- EnterProc('DEC', Dec, notyp);
- EnterProc('EXCL', Excl, notyp);
- EnterProc('FLOAT', Float, realtyp);
- EnterProc('FLOATD', FloatD, lrltyp);
- EnterProc('HALT', Halt, notyp);
- EnterProc('HIGH', High, inttyp);
- EnterProc('INC', Inc, notyp);
- EnterProc('INCL', Incl, notyp);
- EnterProc('LONG', Long, dbltyp);
- EnterProc('MAX', Max, inttyp);
- EnterProc('MIN', Min, inttyp);
- EnterProc('ODD', Odd, booltyp);
- EnterProc('ORD', Ord, inttyp);
- EnterProc('SHORT', Short, inttyp);
- EnterProc('SIZE', Size, inttyp);
- EnterProc('TRUNC', Trunc, inttyp);
- EnterProc('TRUNCD', TruncD, dbltyp);
-
- MarkHeap
-
- END M2TA. (* Copyright Departement Informatik, ETH Zuerich, Switzerland, 1992 *)
-